<script>

export default{
  name: "Student",
  data(){
    return {
      name:'曾宇杰',
      age:18,
      address:'广东梅州'
    }
  },
  methods:{
    sendStudentName(){
      //触发自定义事件
      this.$emit('getStudentName',this.name);
    }
  }


}
</script>

<template>
  <div class="demo">
    <h2>我的叫{{name}}</h2>
    <h2>今年 {{age}}</h2>
    <h2>我家住在{{address}}</h2>
    <button @click="sendStudentName">点我传递学生姓名</button>
  </div>
</template>

<style scoped>
  .demo{
    background-color: gray;
  }
</style>